//
//  EvaluateCell.m
//  趣·美食
//
//  Created by dllo on 15/9/24.
//  Copyright (c) 2015年 金旭. All rights reserved.
//

#import "EvaluateCell.h"


@interface EvaluateCell ()

@property (nonatomic, strong) UIImageView *starView;
@property (nonatomic, strong) UILabel *starLabel;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation EvaluateCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.starView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.starView];
      
        
        self.starLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.starLabel];
      
        
        self.contentLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.contentLabel];
       
    }
    return self;
}


- (void)setDeModel:(GFDetialsModel *)deModel {
    if (_deModel != deModel) {
        
        _deModel = deModel;
    }
    
    switch (self.deModel.health_light) {
        case 1: {
            self.starView.image = [UIImage imageNamed:@"weixiao"];
            self.starLabel.text = @"推 荐";
            self.starLabel.textAlignment = NSTextAlignmentCenter;
            self.starLabel.textColor = [UIColor colorWithRed:77 / 255.0 green:152 / 255.0 blue:17 / 255.0 alpha:1];
            break;
        }
        case 2: {
            self.starView.image = [UIImage imageNamed:@"qin"];
            self.starLabel.text = @"适 量";
            self.starLabel.textAlignment = NSTextAlignmentCenter;
            self.starLabel.textColor = [UIColor colorWithRed:223 / 255.0 green:166 / 255.0 blue:14 / 255.0 alpha:1];
            break;
        }
        case 3: {
            self.starView.image = [UIImage imageNamed:@"bishi"];
            self.starLabel.text = @"少 食";
            self.starLabel.textAlignment = NSTextAlignmentCenter;
            self.starLabel.textColor = [UIColor colorWithRed:216 / 255.0 green:13 / 255.0 blue:27 / 255.0 alpha:1];
            break;
        }
        default: {
            break;
        }
    }
    
    if (self.deModel.appraise.length > 0) {
        self.contentLabel.text = self.deModel.appraise;
    } else {
        self.contentLabel.text = @"暂无评价";
    }
    self.contentLabel.font = [UIFont systemFontOfSize:15];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.starView.frame = CGRectMake(ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 60, ScreenWidth / 375.0 * 60);
    
    self.starLabel.frame = CGRectMake(ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 90, ScreenWidth / 375.0 * 60, ScreenWidth / 375.0 * 20);
    
    if (self.deModel.appraise.length > 0) {
        
    CGFloat h = [GFCalculateWidthOrHeigth stringHeight:self.deModel.appraise withWidth:self.contentView.frame.size.width - ScreenWidth / 375.0 * 120 withFontDictionary:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}];
        self.contentLabel.frame = CGRectMake(ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 20, self.contentView.frame.size.width - 120, h);
    } else {
       CGFloat h = [GFCalculateWidthOrHeigth stringHeight:@"暂无评价" withWidth:self.contentView.frame.size.width - ScreenWidth / 375.0 * 120 withFontDictionary:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}];
        self.contentLabel.frame = CGRectMake(ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 20, self.contentView.frame.size.width - 120, h);
    }
//    self.contentLabel.backgroundColor = [UIColor orangeColor];
    self.contentLabel.numberOfLines = 0;

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
